package com.biz.primus.model.promotion.vo;

import com.biz.primus.base.vo.promotion.PromotionProductVo;
import com.biz.primus.model.promotion.enums.PromotionProductLimitTypeEnum;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 用户首单立减活动Vo
 *
 * @author david-liu
 */
@ApiModel(value = "用户首单立减活动Vo")
@Getter
@Setter
public class UserFirstOrderCutPromotionVo extends BasePromotionVo {
    private static final long serialVersionUID = 7141174857527011461L;

    @ApiModelProperty(value = "不能参与首单立减活动的商品集合")
    private List<PromotionProductVo> excludeProducts;

    @ApiModelProperty(value = "限制不能参与促销活动类型")
    private PromotionProductLimitTypeEnum excludeType = PromotionProductLimitTypeEnum.LIMIT_BY_PRODUCT;

    @ApiModelProperty(value = "促销生效商品金额限制")
    private Integer productAmountLimit;

    @ApiModelProperty(value = "减免金额")
    private Integer cutAmount;

    public List<Long> getExcludeProductIds() {
        return Optional.ofNullable(this.excludeProducts).orElse(Lists.newArrayList()).stream().map(PromotionProductVo::getProductId).collect(Collectors.toList());
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    }
}
